package com.maxatime.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maxatime.pojo.entity.SysDictType;
import com.maxatime.dao.SysDictTypeMapper;
import com.maxatime.service.ISysDictTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Ssb
 * @since 2024-07-15
 */
@Service
public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService {

    @Autowired
    SysDictTypeMapper sysDictTypeMapper;
    @Override
    public Map<String, Object> map(SysDictType sysDictType) {
        PageHelper.startPage(sysDictType.getPageNum(),sysDictType.getPageSize());
        List<SysDictType> list =sysDictTypeMapper.list(sysDictType);
        PageInfo<SysDictType> pageinfo = new PageInfo<SysDictType>(list);
        Map<String, Object> m = new HashMap<>();
        m.put("list", list);
        m.put("pageInfo", pageinfo);
        return m;
    }

    @Override
    public int insertSelective(SysDictType sysDictType) {
        sysDictType.setUpdateBy("admin");
        Date d = new Date();
        sysDictType.setCreateTime(d);
        sysDictType.setUpdateTime(d);
        sysDictTypeMapper.insertSelective(sysDictType);
        return 0;
    }

    @Override
    public Long deleteByPrimaryKey(Long dictId) {
        sysDictTypeMapper.deleteByPrimaryKey(dictId);

        return null;
    }

    @Override
    public SysDictType find(Long dictId) {
        return sysDictTypeMapper.find(dictId);
    }

    @Override
    public int updateByPrimaryKeySelective(SysDictType sysDictType) {
        sysDictTypeMapper.updateByPrimaryKeySelective(sysDictType);
        return 0;
    }


}
